/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exercises.day04.pt01.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 *
 * @author Student
 */
public class Connector {

    private String url = "jdbc:derby://localhost:1527/webshoppe;user=root;password=root";
    private Connection conn;

    public Connector() {
        try {
            //set driver
            Class.forName("org.apache.derby.jdbc.ClientDriver");

            //open connection
            conn = DriverManager.getConnection(url);

        } catch (ClassNotFoundException ex) {
            // Logger.getLogger(Connector.class.getName()).log(Level.SEVERE, null, ex);

             JOptionPane.showMessageDialog(null, "Please load the derby driver."+ ex.getMessage());
        } catch (SQLException ex) {
            // Logger.getLogger(Connector.class.getName()).log(Level.SEVERE, null, ex);
           JOptionPane.showMessageDialog(null, "An SQL Exception was found.  Here's the message: " + ex.getMessage());
        }
    }

    public Connection getConn() {
        return conn;
    }

    public void setConn(Connection conn) {
        this.conn = conn;
    }
}
